package com.zfjt.web;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zfjt.entity.UserApplyBean;
import com.zfjt.entity.UserBean;
import com.zfjt.service.UserApplyService;
import com.zfjt.service.UserService;

@Controller
public class UserApplyWebController{
	
	@Autowired
	private UserApplyService userApplyService;
	
	@Autowired
	private UserService userService;
	
//	把申请用户表添加到用户表里面去
	@RequestMapping("deleteUserApply/{selectedRow}")
	@ResponseBody
	public Integer addUser(UserApplyBean usb){
		UserBean userBean = new UserBean();
		userBean.setUserId(UUID.randomUUID().toString());
		userBean.setAccount(usb.getAccount());
		System.out.println(usb.getName() + "=============");
		userBean.setName(usb.getName());
		userBean.setBranch(usb.getBranch());
		userBean.setMobile(usb.getPhone());
		userBean.setType(usb.getType());
		userBean.setYuliu(usb.getBranchname());
		userBean.setPassword(usb.getPassword());
		userBean.setMoney("0");
		userService.insert(userBean);
		Integer integer = userApplyService.deleteByPrimaryKey(usb.getAccount());
		return integer;
	}
	
//	跳转到用户注册审核展示页面
	@RequestMapping("userApplyCheck")
	public String userApplyCheck(){
		return "user/userApply";
		
	}
	
//	删除申请用户
	@RequestMapping("deleteUserApply/{accs}")
	@ResponseBody
	public Integer deleteUserApply(@PathVariable String accs){
		Integer integer = userApplyService.deleteByPrimaryKey(accs);
		return integer;
		
	}
	
//	跳转到用户注册审核展示页面
	@RequestMapping("userApplyData")
	@ResponseBody
	public List<UserApplyBean> userApplyData(UserBean user){
		List<UserApplyBean> selectAll = userApplyService.selectAll();
		return selectAll;
	}
}
